﻿using BCCommon.Enums;
using BCDto.Common.DeviceInfo;
using BCDto.Common.ErrorMessage;
using BCService.Common.DeviceInfo;
using BCTMSRESTful.Controllers.DriverApp;
using Microsoft.AspNetCore.Mvc;

namespace BCTMSRESTful.Controllers.DriverApp.DeviceInfo
{
    /// <summary>
    /// 设备信息
    /// </summary>
    [ApiExplorerSettings(GroupName = "DriverApp")]
    [Route("api/v1/DriverApp/[controller]")]
    public class DeviceInfoController : DriverAppBaseController
    {
        private readonly IDeviceInfoService deviceInfoService;

        public DeviceInfoController(IDeviceInfoService deviceInfoService)
        {
            this.deviceInfoService = deviceInfoService;
        }

        #region 更新设备信息
        /// <summary>
        /// 更新设备信息。
        /// </summary>
        /// <param name="dto">设备信息</param>
        /// <response code="200"></response>
        /// <response code="400">请求参数或输入的数据不正确。</response>
        /// <response code="401">请求需要认证或者认证信息已过期。</response>
        /// <response code="403">无权访问指定的功能。</response>
        /// <response code="500">服务器发生错误。</response>
        /// <response code="501">某些功能尚未实现。</response>
        /// <returns></returns>
        [HttpPut]
        [ProducesResponseType(typeof(OkObjectResult), 200)]
        [ProducesResponseType(typeof(ErrorMessageDto), 400)]
        [ProducesResponseType(typeof(ErrorMessageDto), 500)]
        public IActionResult Put([FromBody]DeviceInfoPutDto dto)
        {
            this.deviceInfoService.UpdateAsync(this.UserInfo, AppType.DriverApp, dto);
            return this.Ok();
        }
        #endregion
    }
}
